/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.FUNCTION.PASSBOOK;

import DAO.DataAccessObject;
import GUI.MAINMENU.Home;
import GUI.FUNCTION.CUSTOMER.*;
import GUI.Main;
import java.awt.Color;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.JXComboBox;

/**
 *
 * @author wonka
 */
public class FunctionAddPassBook extends org.jdesktop.swingx.JXPanel {
    private     org.jdesktop.swingx.JXPanel workPanel;
    private String[] detailLTK;
    /**
     * Creates new form Home
     */
    public FunctionAddPassBook() {
        initComponents();
        cb_MaLTK.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                    txt_LoaiTietKiem.setText(detailLTK[0]);
                    txt_KyHan.setText(detailLTK[1]);
                    txt_HTTL.setText( detailLTK[2]);
                    txt_LaiSuat.setText(  detailLTK[3]);
                    txt_DonViTien.setText(  detailLTK[4]);
            }
        });
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jXLabel2 = new org.jdesktop.swingx.JXLabel();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        jXLabel1 = new org.jdesktop.swingx.JXLabel();
        jXLabel3 = new org.jdesktop.swingx.JXLabel();
        jXLabel4 = new org.jdesktop.swingx.JXLabel();
        jXLabel6 = new org.jdesktop.swingx.JXLabel();
        jXDatePicker1 = new org.jdesktop.swingx.JXDatePicker();
        jXLabel8 = new org.jdesktop.swingx.JXLabel();
        txt_LoaiTietKiem = new org.jdesktop.swingx.JXTextField();
        jXButton1 = new org.jdesktop.swingx.JXButton();
        jXButton3 = new org.jdesktop.swingx.JXButton();
        jXTextField3 = new org.jdesktop.swingx.JXTextField();
        jXLabel7 = new org.jdesktop.swingx.JXLabel();
        jXDatePicker2 = new org.jdesktop.swingx.JXDatePicker();
        cb_MaKH = new org.jdesktop.swingx.JXComboBox();
        jXLabel10 = new org.jdesktop.swingx.JXLabel();
        txt_KyHan = new org.jdesktop.swingx.JXTextField();
        jXLabel11 = new org.jdesktop.swingx.JXLabel();
        txt_HTTL = new org.jdesktop.swingx.JXTextField();
        jXLabel12 = new org.jdesktop.swingx.JXLabel();
        txt_LaiSuat = new org.jdesktop.swingx.JXTextField();
        jXLabel13 = new org.jdesktop.swingx.JXLabel();
        txt_DonViTien = new org.jdesktop.swingx.JXTextField();
        jXButton4 = new org.jdesktop.swingx.JXButton();
        jXLabel14 = new org.jdesktop.swingx.JXLabel();
        jXTextField12 = new org.jdesktop.swingx.JXTextField();
        cb_MaLTK = new org.jdesktop.swingx.JXComboBox();

        setBackground(new java.awt.Color(255, 253, 218));
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        setAutoscrolls(true);
        setScrollableHeightHint(org.jdesktop.swingx.ScrollableSizeHint.FIT);
        setScrollableWidthHint(org.jdesktop.swingx.ScrollableSizeHint.FIT);
        addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                formAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        jXLabel2.setBackground(new java.awt.Color(153, 255, 255));
        jXLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Medium_AddPassBook.png"))); // NOI18N
        jXLabel2.setText("Mở Sổ");
        jXLabel2.setFont(new java.awt.Font("Segoe UI Semibold", 1, 18)); // NOI18N

        jXPanel1.setBackground(new java.awt.Color(255, 253, 218));
        jXPanel1.setMinimumSize(new java.awt.Dimension(686, 470));
        jXPanel1.setPreferredSize(new java.awt.Dimension(686, 470));
        jXPanel1.setLayout(new java.awt.GridBagLayout());

        jXLabel1.setText("Mã Sổ");
        jXLabel1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(34, 52, 0, 0);
        jXPanel1.add(jXLabel1, gridBagConstraints);

        jXLabel3.setText("Mã Khách Hàng:");
        jXLabel3.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 24;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(29, 15, 0, 0);
        jXPanel1.add(jXLabel3, gridBagConstraints);

        jXLabel4.setText("Ngày Mở Sổ");
        jXLabel4.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(24, 49, 0, 0);
        jXPanel1.add(jXLabel4, gridBagConstraints);

        jXLabel6.setText("Mã Loại Tiết Kiệm:");
        jXLabel6.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(42, 52, 0, 0);
        jXPanel1.add(jXLabel6, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.gridwidth = 6;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.ipady = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(18, 18, 0, 0);
        jXPanel1.add(jXDatePicker1, gridBagConstraints);

        jXLabel8.setText("Loại Tiết Kiệm:");
        jXLabel8.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 24;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(35, 15, 0, 0);
        jXPanel1.add(jXLabel8, gridBagConstraints);

        txt_LoaiTietKiem.setEnabled(false);
        txt_LoaiTietKiem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_LoaiTietKiemActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 29;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.ipadx = 176;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(30, 21, 0, 21);
        jXPanel1.add(txt_LoaiTietKiem, gridBagConstraints);

        jXButton1.setBackground(new java.awt.Color(255, 255, 51));
        jXButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 102, 0)));
        jXButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Small_Close.png"))); // NOI18N
        jXButton1.setText("Thoát");
        jXButton1.setFocusPainted(false);
        jXButton1.setMaximumSize(new java.awt.Dimension(150, 40));
        jXButton1.setMinimumSize(new java.awt.Dimension(150, 40));
        jXButton1.setPreferredSize(new java.awt.Dimension(130, 40));
        jXButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 29;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(46, 21, 21, 0);
        jXPanel1.add(jXButton1, gridBagConstraints);

        jXButton3.setBackground(new java.awt.Color(255, 255, 51));
        jXButton3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 102, 0)));
        jXButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Small_Bills.png"))); // NOI18N
        jXButton3.setText("Xuất Phiếu Gửi");
        jXButton3.setFocusPainted(false);
        jXButton3.setMaximumSize(new java.awt.Dimension(150, 40));
        jXButton3.setMinimumSize(new java.awt.Dimension(150, 40));
        jXButton3.setPreferredSize(new java.awt.Dimension(130, 40));
        jXButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton3ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 13;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.gridwidth = 11;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(46, 3, 21, 0);
        jXPanel1.add(jXButton3, gridBagConstraints);

        jXTextField3.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 7;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.ipadx = 157;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(29, 18, 0, 0);
        jXPanel1.add(jXTextField3, gridBagConstraints);

        jXLabel7.setText("Ngày Đến Hạn");
        jXLabel7.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 24;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(31, 15, 0, 0);
        jXPanel1.add(jXLabel7, gridBagConstraints);

        jXDatePicker2.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 29;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.ipady = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(25, 21, 0, 0);
        jXPanel1.add(jXDatePicker2, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 29;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.ipadx = 154;
        gridBagConstraints.ipady = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(23, 21, 0, 21);
        jXPanel1.add(cb_MaKH, gridBagConstraints);

        jXLabel10.setText("Kỳ Hạn: ");
        jXLabel10.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(33, 49, 0, 0);
        jXPanel1.add(jXLabel10, gridBagConstraints);

        txt_KyHan.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = 8;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.ipadx = 160;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(28, 18, 0, 0);
        jXPanel1.add(txt_KyHan, gridBagConstraints);

        jXLabel11.setText("Hình Thức Trả Lãi:");
        jXLabel11.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 24;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(33, 15, 0, 0);
        jXPanel1.add(jXLabel11, gridBagConstraints);

        txt_HTTL.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 29;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.ipadx = 176;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(28, 21, 0, 21);
        jXPanel1.add(txt_HTTL, gridBagConstraints);

        jXLabel12.setText("Lãi Suất");
        jXLabel12.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(35, 52, 0, 0);
        jXPanel1.add(jXLabel12, gridBagConstraints);

        txt_LaiSuat.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 8;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.ipadx = 160;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(30, 18, 0, 0);
        jXPanel1.add(txt_LaiSuat, gridBagConstraints);

        jXLabel13.setText("Đơn Vị Tiền: ");
        jXLabel13.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 24;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(42, 15, 0, 0);
        jXPanel1.add(jXLabel13, gridBagConstraints);

        txt_DonViTien.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 29;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.ipadx = 176;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(37, 21, 0, 21);
        jXPanel1.add(txt_DonViTien, gridBagConstraints);

        jXButton4.setBackground(new java.awt.Color(255, 255, 51));
        jXButton4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 102, 0)));
        jXButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Small_Save.png"))); // NOI18N
        jXButton4.setText("Thêm và Lưu");
        jXButton4.setFocusPainted(false);
        jXButton4.setMaximumSize(new java.awt.Dimension(150, 40));
        jXButton4.setMinimumSize(new java.awt.Dimension(150, 40));
        jXButton4.setPreferredSize(new java.awt.Dimension(130, 40));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(46, 82, 21, 0);
        jXPanel1.add(jXButton4, gridBagConstraints);

        jXLabel14.setText("Số Tiền Gửi:");
        jXLabel14.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 18;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(27, 49, 0, 0);
        jXPanel1.add(jXLabel14, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 18;
        gridBagConstraints.gridwidth = 10;
        gridBagConstraints.ipadx = 275;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(11, 18, 0, 0);
        jXPanel1.add(jXTextField12, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 9;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.ipadx = 154;
        gridBagConstraints.ipady = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(36, 18, 0, 0);
        jXPanel1.add(cb_MaLTK, gridBagConstraints);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 861, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 451, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jXButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton3ActionPerformed

    private void txt_LoaiTietKiemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_LoaiTietKiemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txt_LoaiTietKiemActionPerformed

    private void jXButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton1ActionPerformed
        // TODO add your handling code here:
        Home child = new Home();
        child.setVisible(true);
        child.setSize( this.getSize());
        this.removeAll();
        this.add(child);
        this.validate();
        this.repaint();
    }//GEN-LAST:event_jXButton1ActionPerformed

    private void formAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_formAncestorAdded
        // TODO add your handling code here:
        DataAccessObject dao = new DataAccessObject();
        try {
//            ResultSet res = new DataAccessObject().Select("KHACH_HANG", "MA_KH ");
//            AddItemToComboBox(res,cb_MaKH);
            ResultSet res= new DataAccessObject().Select("LOAITIETKIEM", "MA_LOAITIETKIEM");
           AddItemToComboBox(res,cb_MaLTK);
           res= new DataAccessObject().Select("LOAITIETKIEM, LOAITIEN", "TEN_LOAITIETKIEM, KYHAN, HINHTHUC_TRALAI, LAISUAT, DON_VI_TIEN",
                    "LOAITIETKIEM.MA_LOAITIEN = LOAITIEN.MA_LOAITIEN AND LOAITIETKIEM.MA_LOAITIETKIEM = '"+ cb_MaLTK.getItemAt(0).toString().trim()+"'");
            
             while (res.next()) 
            {
                    detailLTK[0] = res.getObject(1).toString();
                    txt_LoaiTietKiem.setText(detailLTK[0]);
                      detailLTK[1] = res.getObject(2).toString();
                    txt_KyHan.setText(detailLTK[1]);
                      detailLTK[2] = res.getObject(3).toString();
                    txt_HTTL.setText( detailLTK[2]);
                      detailLTK[3] = res.getObject(4).toString();
                    txt_LaiSuat.setText(  detailLTK[3]);
                      detailLTK[4] = res.getObject(5).toString();
                    txt_DonViTien.setText(  detailLTK[4]);
            }
            
        } catch (Exception ex) {
            Logger.getLogger(FunctionAddPassBook.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_formAncestorAdded
public void AddItemToComboBox(ResultSet rs, final JXComboBox cmb){
    try {
    final List<String> allItems = new ArrayList<String>();
    while(rs.next()) {
        String result = rs.getString(1);
        if (result != null) {
            result = result.trim();
        }
        allItems.add(result);
    }
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
        for (String item: allItems) {
                cmb.addItem(item);
            }
        }
    });
     }catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
    }}
}
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXComboBox cb_MaKH;
    private org.jdesktop.swingx.JXComboBox cb_MaLTK;
    private org.jdesktop.swingx.JXButton jXButton1;
    private org.jdesktop.swingx.JXButton jXButton3;
    private org.jdesktop.swingx.JXButton jXButton4;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker1;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker2;
    private org.jdesktop.swingx.JXLabel jXLabel1;
    private org.jdesktop.swingx.JXLabel jXLabel10;
    private org.jdesktop.swingx.JXLabel jXLabel11;
    private org.jdesktop.swingx.JXLabel jXLabel12;
    private org.jdesktop.swingx.JXLabel jXLabel13;
    private org.jdesktop.swingx.JXLabel jXLabel14;
    private org.jdesktop.swingx.JXLabel jXLabel2;
    private org.jdesktop.swingx.JXLabel jXLabel3;
    private org.jdesktop.swingx.JXLabel jXLabel4;
    private org.jdesktop.swingx.JXLabel jXLabel6;
    private org.jdesktop.swingx.JXLabel jXLabel7;
    private org.jdesktop.swingx.JXLabel jXLabel8;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXTextField jXTextField12;
    private org.jdesktop.swingx.JXTextField jXTextField3;
    private org.jdesktop.swingx.JXTextField txt_DonViTien;
    private org.jdesktop.swingx.JXTextField txt_HTTL;
    private org.jdesktop.swingx.JXTextField txt_KyHan;
    private org.jdesktop.swingx.JXTextField txt_LaiSuat;
    private org.jdesktop.swingx.JXTextField txt_LoaiTietKiem;
    // End of variables declaration//GEN-END:variables
}
